package com.androidviewx.badge;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.RoundRectShape;
import android.graphics.drawable.shapes.Shape;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.TextView;
import android.widget.Toast;
public final class AppToast {
    public static  void show(Context context, String message) {
        show(context, TextUtils.isEmpty((CharSequence)message) ? "" : message, 0);
    }
    public static void show(Context context, String message, int duration) {
        Toast toast = new Toast(context);
        toast.setDuration(duration);
        toast.setGravity(17, 0, 0);
        String var10003 = message;
        if (message == null) {
            var10003 = "";
        }
        toast.setView(createTextToastView(context, var10003));
        toast.show();
    }

    private static View createTextToastView(Context context, String message) {
        float rc = (float)dp2px(context, 3.0F);
        RoundRectShape shape = new RoundRectShape(new float[]{rc, rc, rc, rc, rc, rc, rc, rc}, (RectF)null, (float[])null);
        ShapeDrawable drawable = new ShapeDrawable((Shape)shape);
        Paint var10000 = drawable.getPaint();
        var10000.setColor(Color.argb(204, 0, 0, 0));
        var10000 = drawable.getPaint();
        var10000.setStyle(Paint.Style.FILL);
        var10000 = drawable.getPaint();
        var10000.setAntiAlias(true);
        var10000 = drawable.getPaint();
        var10000.setFlags(Paint.ANTI_ALIAS_FLAG);
        FrameLayout layout = new FrameLayout(context);
        ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(-2, -2);
        layout.setLayoutParams(layoutParams);
        layout.setPadding(dp2px(context, 16.0F), dp2px(context, 12.0F), dp2px(context, 16.0F), dp2px(context, 12.0F));
        layout.setBackground((Drawable)drawable);
        TextView textView = new TextView(context);
        textView.setLayoutParams((ViewGroup.LayoutParams)(new FrameLayout.LayoutParams(-2, -2)));
        textView.setTextSize(1, 14.0F);
        textView.setText((CharSequence)message);
        textView.setLineSpacing((float)dp2px(context, 4.0F), 1.0F);
        textView.setTextColor(-1);
        layout.addView((View)textView);
        return (View)layout;
    }

    private static int dp2px(Context context, float dpValue) {
        Resources var10000 = context.getResources();
        float scale = var10000.getDisplayMetrics().density;
        return (int)(dpValue * scale + 0.5F);
    }
}